//
//  UIButton+Extention.swift
//  JJWeibo
//
//  Created by JJ on 15/9/7.
//  Copyright © 2015年 JJ. All rights reserved.
//

import UIKit

extension UIButton {
    
    convenience init(titil:String,imageName:String,color:UIColor,fontSize:CGFloat){
        
        self.init()
        
        setTitle(titil, forState: UIControlState.Normal)
        setImage(UIImage(named: imageName), forState: UIControlState.Normal)
        setTitleColor(color, forState: UIControlState.Normal)
        titleLabel?.font=UIFont.systemFontOfSize(fontSize)
       
    }
    
    convenience init(titil:String,fontSize:CGFloat,color:UIColor=UIColor.whiteColor(),backColor:UIColor=UIColor.darkGrayColor()){
        
        self.init()
        
        setTitle(titil, forState: UIControlState.Normal)

        titleLabel?.font=UIFont.systemFontOfSize(fontSize)
        
        setTitleColor(color, forState: UIControlState.Normal)
        backgroundColor=backColor
        
    }
    convenience init(imageName:String){
        self.init()
        
        setImage(UIImage(named: imageName), forState: UIControlState.Normal)
        setImage(UIImage(named: imageName + "_highlighted"), forState: UIControlState.Highlighted)
        
        sizeToFit()
    }
}